package de.thm.exa.helpers;

import de.thm.exa.holders.TestResult;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;

public class FileWriter
{
    public static void write(File file, TestResult result) throws IOException
    {
        System.out.println("Writing file...");
        
        String resultString = result.toString();
        
        BufferedWriter bw = new BufferedWriter(new java.io.FileWriter(file, true));
        bw.write( resultString, 0, resultString.length() );
        bw.close();
        
        System.out.println("Ended writing file.");
    }
    
    public static void writeHeader(File file) throws IOException
    {
        String header = "Name;Time (ms);Collisions;Inserts;Rehashes;Function(s);List Size(s);Success\n";
        BufferedWriter bw = new BufferedWriter(new java.io.FileWriter(file, true));
        bw.write( header, 0, header.length() );
        bw.close();
    }
}
